﻿using System;
using System.Collections.Generic;
using System.Text;

namespace UtilZ.Dotnet.Ex.Model
{
    /// <summary>
    /// 区域坐标
    /// </summary>
    public struct RegionCoordnates
    {
        /// <summary>
        /// 较小的X
        /// </summary>
        public int MinX { get; private set; }

        /// <summary>
        /// 较大的X
        /// </summary>
        public int MaxX { get; private set; }

        /// <summary>
        /// X宽度
        /// </summary>
        public int Width { get; private set; }

        /// <summary>
        /// 较小的Y
        /// </summary>
        public int MinY { get; private set; }

        /// <summary>
        /// 较大的Y
        /// </summary>
        public int MaxY { get; private set; }

        /// <summary>
        /// Y高度
        /// </summary>
        public int Height { get; private set; }


        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="x1">水平X第一个坐标</param>
        /// <param name="x2">水平X第二个坐标</param>
        /// <param name="y1">垂直Y第一个坐标</param>
        /// <param name="y2">垂直Y第二个坐标</param>
        public RegionCoordnates(int x1, int x2, int y1, int y2)
        {
            int beginX, endX, beginY, endY;
            if (x1 < x2)
            {
                beginX = x1;
                endX = x2;
            }
            else
            {
                beginX = x2;
                endX = x1;
            }

            if (y1 < y2)
            {
                beginY = y1;
                endY = y2;
            }
            else
            {
                beginY = y2;
                endY = y1;
            }

            this.MinX = beginX;
            this.MaxX = endX;
            this.Width = endX - beginX;
            this.MinY = beginY;
            this.MaxY = endY;
            this.Height = endY - beginY;
        }
    }
}
